<?
include_once 'includes/utilities.php';
$link = OpenDB();
$codigo = mysql_real_escape_string($_POST["codigo"]);
    $query = "delete from template_pap_diagnostico_pap where codigo = '" . $codigo."'";
    $clear = PostSQL($query);
    foreach ($_POST as $key => $value)
    {
        if ($value == "on")
        {
            $query = "insert into template_pap_diagnostico_pap (codigo, codigo_diagnostico_pap) values
                            ('" . $codigo . "', '" . $key . "')";
            $insert = PostSQL($query);
        }
    }
    $commit = PostSQL("COMMIT");
CloseDB($link);
header("Location: templatePapDiagnostico.php?codigo=".$codigo);
?>
